import type {
  IGetCodeData,
  IGetCodeParams,
  LoginCodeData,
  LoginCodeParams,
  LoginDataType,
  LoginParams,
  UserData,
} from '@/types/user'
import request from '@/utils/request'

export const loginByPasswordAPI = (data: LoginParams) => {
  // 第二个泛型参数, 写后端给响应数据的data类型即可
  return request.post<null, LoginDataType>('/login/password', data)
}

/** 获取验证码的API函数 */
export const getCodeAPI = (params: IGetCodeParams) => {
  return request.get<null, IGetCodeData>('/code', { params })
}

/**
 * 用户登录接口（短信验证码方式）
 */
export const loginByMobileApi = (data: LoginCodeParams) => {
  return request.post<null, LoginCodeData>('/login', data)
}

export const loginByWXAPI = (data: any) => {
  return request.post('/login/wxMin', data)
}

/** 查询个人信息 */
export const getUserInfoApi = () => {
  return request.get<null, UserData>('/patient/myUser')
}
